package com.example.jack.community.view.me.personinfo;

import android.content.Context;
import android.os.Bundle;
import android.support.percent.PercentRelativeLayout;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.jack.community.R;
import com.example.jack.community.view.me.BlackStatusActivity;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import cn.pedant.SweetAlert.SweetAlertDialog;


/**
 * 我的签名
 */
public class MysignatureActivity extends BlackStatusActivity {

    @BindView(R.id.back)
    ImageView back;
    @BindView(R.id.text_return)
    TextView textReturn;
    @BindView(R.id.filla)
    PercentRelativeLayout filla;
    @BindView(R.id.activity_mysignature)
    PercentRelativeLayout activityMysignature;
    @BindView(R.id.text_cal)
    TextView textCal;
    @BindView(R.id.edit)
    EditText edit;
    @BindView(R.id.finish_text)
    TextView finishText;
    @BindView(R.id.per_edit)
    PercentRelativeLayout perEdit;
    private static final String TAG = "TonJie";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_mysignature);
        ButterKnife.bind(this);
        //计算输入框输入个数
        edit_cal();
    }

    private void edit_cal() {
        edit.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {

            }

            @Override
            public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {

            }

            @Override
            public void afterTextChanged(Editable editable) {
                textCal.setText("" + editable.length());
            }
        });
    }

    @OnClick({R.id.per_edit, R.id.back, R.id.text_return, R.id.finish_text})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.per_edit:
                edit.requestFocus();
                InputMethodManager imms = (InputMethodManager) edit.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
                imms.toggleSoftInput(0, InputMethodManager.SHOW_FORCED);
                break;
            case R.id.finish_text:
                new SweetAlertDialog(this, SweetAlertDialog.SUCCESS_TYPE)
                        .setTitleText("Hello World")
                        .setContentText("Set up the success")
                        .setConfirmClickListener(new SweetAlertDialog.OnSweetClickListener() {
                            @Override
                            public void onClick(SweetAlertDialog sweetAlertDialog) {
//                                Toast.makeText(MysignatureActivity.this, "Hello", Toast.LENGTH_SHORT).show();
                                finish();
                            }
                        })
                        .show();
//                finish();
                break;
            case R.id.back:
                finish();
                break;
            case R.id.text_return:
                finish();
                break;
        }
    }
}
